package health.lm.com.home.presenter;

import java.util.ArrayList;
import java.util.List;

import health.lm.com.component_base.base.mvp.contract.XPresent;
import health.lm.com.home.entity.NoticesEntity;
import health.lm.com.home.entity.NoticesResponseEntity;
import health.lm.com.home.fragment.NoticesView;
import health.lm.com.home.model.HomeModel;
import health.lm.com.network.callback.SimpleCallBack;

/**
 * Created by Android Studio .
 * Project：hlian health.lm.com.home.presenter
 * Date：2019/8/7 17:02
 * Introduce：hlian
 */
public class NoticesPresenter extends XPresent<NoticesView> {
    /**
     * 获取会链通知
     */
    public void getHuiChainNotices(boolean isRefresh, int page, int pageSize) {
        HomeModel.getInstance().getNoticeData(1, page, pageSize, new SimpleCallBack<NoticesResponseEntity>() {
            @Override
            public void onSuccess(NoticesResponseEntity pNoticesResponseEntity) {
                if (hasV()) getV().setNewData(pNoticesResponseEntity.getList());
            }
        });
    }

    /**
     * 获取商会通知
     */
    public void getBusinessNotices(boolean isRefresh, int page, int pageSize) {
        HomeModel.getInstance().getNoticeData(2, page, pageSize, new SimpleCallBack<NoticesResponseEntity>() {
            @Override
            public void onSuccess(NoticesResponseEntity pNoticesResponseEntity) {
                if (hasV()) getV().setNewData(pNoticesResponseEntity.getList());
            }
        });
    }

    private List<NoticesEntity> dataSource() {
        List<NoticesEntity> entities = new ArrayList<>();
        for (int a = 0; a < 10; a++) {
            NoticesEntity entity = new NoticesEntity();
            entity.setId(a);
            entity.setIsReadd(a % 2 == 0 ? 1 : 0);
            entity.setImage("http://image109.360doc.com/DownloadImg/2018/03/1008/126782666_1_2018031008485635.jpeg");
            entity.setTime("2019-8-11 08:23");
            entity.setTitle("你报名的活动马上就要开始了");
            entity.setNewsletter("会链举行”党组书记上党课“活动即将开始了，党课即时直播，市工商联机关党支部全体党员共同参与。");
            entities.add(entity);
        }
        return entities;
    }
}
